<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('项目成本预估列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>项目编号：</label>
                                <input type="text" autoComplete="off" name="orderNo"/>
                            </li>
                            <li>
                                <label>项目名称：</label>
                                <input type="text" autoComplete="off" name="xmmc"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <!-- 总经理审核 -->
                <a class="btn btn-info multiple disabled" id="button-zjlyes" >
                    <i class="fa fa-check"></i> 审核通过
                </a>
                <a class="btn btn-danger multiple disabled" id="button-zjlno" >
                    <i class="fa fa-remove"></i> 审核拒绝
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('gcgl:cbpj:edit')}]];
        var prefix = ctx + "gcgl/cbpj";
        var datas = [[${@dict.getType('gcgl_cbpg_status')}]];

        $(function() {
            var options = {
                url: prefix + "/gcpslist",
                detailUrl: prefix + "/cbyggcsp/{id}",
                removeUrl: prefix + "/remove",
                modalName: "项目成本预估",
                sortName: "orderno desc",
                sortOrder: "",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'orderNo',
                    title: '项目编号'
                },
                {
                    field: 'xmfzr',
                    title: '项目负责人',
                    visible: false
                },
                {
                    field: 'xmmc',
                    title: '项目名称'
                },
                {
                    field: 'customerName',
                    title: '单位名称'
                },
                {
                    field: 'pgsj',
                    title: '评估时间',
                    visible: false,
                    width:'90'
                },
                {
                    field: 'cbhj',
                    title: '成本合计',
                    visible: false
                },
                {
                    field: 'lryg',
                    title: '利润预估',
                    visible: false
                },
                {
                    field: 'xmjlsh',
                    title: '工程经理审核'
                },
                {
                    field: 'zjlsh',
                    title: '总经理审核'
                },
                {
		            field: 'status',
		            title: '状态',
		            align: "left",
		            formatter: function(value, item, index) {
		            	return $.table.selectDictLabel(datas, item.status);
		            }
		        },
		        {
                    field: 'spyj',
                    title: '审批意见',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.detailTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        
	    //总经理审核
	    $("#button-zjlyes").click(function(){
        	table.set();
        	var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
            if (rows.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
        	
	    	$.modal.confirm("确认要审核通过吗?", function() {
	    		$.ajax({
    				url: "/gcgl/cbpj/gcyes",
    				type: "post",
    				data: { "ids": rows.join() },
    				dataType: 'json',
    				success: function(data) {
    					$.table.refresh();
    				},
    				error: function(xhr, type, errorThrown) {
    					//异常处理；
    					$.modal.alert("请稍后再试！");
    					$.table.refresh();
    				}
    			});
	    	});
	    })
	    
	    $("#button-zjlno").click(function(){
        	table.set();
        	var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
            if (rows.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
        	
	    	$.modal.confirm("确认要审核拒绝吗?", function() {
	    		$.ajax({
    				url: "/gcgl/cbpj/gcno",
    				type: "post",
    				data: { "ids": rows.join() },
    				dataType: 'json',
    				success: function(data) {
    					$.table.refresh();
    				},
    				error: function(xhr, type, errorThrown) {
    					//异常处理；
    					$.modal.alert("请稍后再试！");
    					$.table.refresh();
    				}
    			});
	    	});
	    })
    </script>
</body>
</html>